package com.taxshare.seller.controller;

import cn.hutool.core.collection.CollUtil;
import com.taxshare.pvalidate.ParamValid;
import com.taxshare.response.beans.Response;
import com.taxshare.seller.service.CarCategoryService;
import com.taxshare.seller.service.CarProductionPlaceService;
import com.taxshare.seller.view.dto.CarCategoryDTO;
import com.taxshare.seller.view.dto.CarProductionPlaceDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author cxl
 * @date 2021/8/19 13:15
 */
@RestController
@RequestMapping("/carProductionPlace")
@Api(tags = "车辆产地信息")
public class CarProductionPlaceController {

    @Autowired
    CarProductionPlaceService carProductionPlaceService;

    @PostMapping("/add")
    @ApiOperation(value = "车辆产地信息新增", notes = "车辆产地信息")
    @ParamValid
    public Response addProductionPlace(@RequestBody @Valid CarProductionPlaceDTO placeDTO) {
        return carProductionPlaceService.addProductionPlace(placeDTO);
    }

    @GetMapping("/remove")
    @ApiOperation(value = "车辆产地信息删除", notes = "车辆产地信息")
    public Response removeProductionPlace(String[] ids) {

        return carProductionPlaceService.removeProductionPlace(CollUtil.toList(ids));
    }

    @PostMapping("/edit")
    @ApiOperation(value = "车辆产地信息编辑", notes = "车辆产地信息")
    public Response editProductionPlace(@RequestBody CarProductionPlaceDTO placeDTO) {
        return carProductionPlaceService.editProductionPlace(placeDTO);
    }

    @GetMapping("/list")
    @ApiOperation(value = "车辆产地信息查询", notes = "车辆产地信息")
    public Response listProductionPlaceByKeyword(String keyword) {
        return carProductionPlaceService.listProductionPlaceByKeyword(keyword);
    }
}
